<?php

namespace app\proxy\controller\store;

use app\common\model\settings\Region as RegionModel;
use app\Request;
use app\proxy\controller\Controller;
use app\proxy\model\store\Store as StoreModel;

/**
 * 门店控制器
 */
class Store extends Controller
{
    /**
     * 门店列表
     */
    public function index()
    {
        $model = new StoreModel;
        $list = $model->getList($this->postData(), '', $this->getRegionIds(),$this->getProxyId());

        foreach ($list as $key => $val) {
            $list[$key]['detail_address'] = $val['region']['province'] . $val['region']['city'] . $val['region']['region'] . $val['address'];
        }

        return $this->renderSuccess('', compact('list'));
    }


    public function checkStoreClick(Request $request)
    {
        $params = $request->param();
        $model = StoreModel::where('store_id', '=', $params['store_id'])->find();
        if ($params['check_store'] == 2) {
            $model['refuse_content'] = $params['refuse_content'];
        } else {
            $model['refuse_content'] = '';
        }
        $model['check_store'] = $params['check_store'];
        $model->save();
        return $this->renderSuccess('操作成功');
    }


}
